<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;}
        div {
            background-color: violet;
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>

    <script src="./lib/template-web.js"></script>

    <script type="text/template" id="tmp">
        <!-- 简单的模板 -->
        <h1>我是模板里面的代码~</h1>
        <p>{{ title }}</p>
        <h1><%= num + 49 %></h1>
        {{ each arr }}
            <p>{{ $index + 1 }} --- {{ $value }}</p>
        {{ /each }}
    </script>

    <script>
        var arr = ['red', 'green', 'blue']
        var str = template('tmp', { title: 'one', num: 129, arr: arr })
        console.log(str)
        document.querySelector('.box1').innerHTML = str
    </script>
</body>
</html>